package org.jackysoft.jms;

import javax.annotation.Resource;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.util.HtmlUtils;


@Component
public class MessageReceiver implements MessageListener {

	static final Log logger = LogFactory.getLog(MessageReceiver.class);
	private MyMessageConverter converter;
	


	@Resource
	public void setConverter(MyMessageConverter converter) {
		this.converter = converter;
	}


	@Override
	public void onMessage(Message arg0) {
		try {
			if (arg0 instanceof TextMessage) {

			   String text = ((TextMessage) arg0).getText();
			   text = HtmlUtils.htmlUnescape(text);
               logger.info("收到消息: "+text);
			}
		} catch (JMSException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
